<html>
<head><meta charset="utf-8"><title>Panic in json-format · rustdoc · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/index.html">rustdoc</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Panic.20in.20json-format.html">Panic in json-format</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="218899256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Panic%20in%20json-format/near/218899256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nixon Enraght-Moony <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Panic.20in.20json-format.html#218899256">(Dec 04 2020 at 22:27)</a>:</h4>
<p>Turns out <a href="https://github.com/rust-lang/rust/pull/75114/files#r519470764">that change around CRATE_DEF_INDEX</a> was deffinatly needed. I'm working on a minimal reproduction <a href="https://github.com/aDotInTheVoid/xmark/issues/5">here</a>. More details to come as I figure it out</p>



<a name="218899516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Panic%20in%20json-format/near/218899516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Panic.20in.20json-format.html#218899516">(Dec 04 2020 at 22:30)</a>:</h4>
<p>do you know yet <em>why</em> it's necessary? It seems like <code>output.root</code> is getting overridden with an import somehow? I'd expect that to need larger changes than changing the DefId, lots of rustdoc has fake defids</p>



<a name="218899923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Panic%20in%20json-format/near/218899923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nixon Enraght-Moony <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Panic.20in.20json-format.html#218899923">(Dec 04 2020 at 22:35)</a>:</h4>
<p>Yeah, it seems like something else is getting Id <code>0:0</code>, and that messes up the assuptions about what root has.</p>



<a name="218903342"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Panic%20in%20json-format/near/218903342" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nixon Enraght-Moony <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Panic.20in.20json-format.html#218903342">(Dec 04 2020 at 23:14)</a>:</h4>
<p>Minimal:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">mod</span> <span class="nn">l1</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">mod</span> <span class="nn">l3</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">L4</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">use</span><span class="w"> </span><span class="n">l3</span>::<span class="n">L4</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="218906763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Panic%20in%20json-format/near/218906763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nixon Enraght-Moony <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Panic.20in.20json-format.html#218906763">(Dec 05 2020 at 00:07)</a>:</h4>
<p>Checking the inserts are unique, it turns out theirs a lot of collisions</p>



<a name="218906878"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Panic%20in%20json-format/near/218906878" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Panic.20in.20json-format.html#218906878">(Dec 05 2020 at 00:09)</a>:</h4>
<p>Yeah I think rustdoc reuses DefIds for a lot of things</p>



<a name="218906894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Panic%20in%20json-format/near/218906894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Panic.20in.20json-format.html#218906894">(Dec 05 2020 at 00:09)</a>:</h4>
<p>Maybe a fix is to use a different id that's unique and unrelated to DefIds?</p>



<a name="218907104"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Panic%20in%20json-format/near/218907104" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nixon Enraght-Moony <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Panic.20in.20json-format.html#218907104">(Dec 05 2020 at 00:13)</a>:</h4>
<p>Would that be any simpler than not reusing <code>DefIds</code>. They seem to be unique in the compiller. Any reasons they can't be made unique?</p>



<a name="218907863"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Panic%20in%20json-format/near/218907863" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Panic.20in.20json-format.html#218907863">(Dec 05 2020 at 00:27)</a>:</h4>
<p>well, it's unique within the compiler, but not within rustdoc</p>



<a name="218907939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Panic%20in%20json-format/near/218907939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Panic.20in.20json-format.html#218907939">(Dec 05 2020 at 00:28)</a>:</h4>
<p>hmm, actually I'm having trouble finding where it's duplicated other than in that one case</p>



<a name="218907957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Panic%20in%20json-format/near/218907957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Panic.20in.20json-format.html#218907957">(Dec 05 2020 at 00:29)</a>:</h4>
<p>maybe we <em>could</em> just use <code>cx.next_def_id</code>?</p>



<a name="218907974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Panic%20in%20json-format/near/218907974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Panic.20in.20json-format.html#218907974">(Dec 05 2020 at 00:29)</a>:</h4>
<p>but that seems like a hack - you can't pass those DefIds to anything in rustc</p>



<a name="218907977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Panic%20in%20json-format/near/218907977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Panic.20in.20json-format.html#218907977">(Dec 05 2020 at 00:29)</a>:</h4>
<p>it will panic</p>



<a name="218934037"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Panic%20in%20json-format/near/218934037" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nixon Enraght-Moony <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Panic.20in.20json-format.html#218934037">(Dec 05 2020 at 12:53)</a>:</h4>
<p>Using <code>cx.tcx.hir().local_def_id(self.id).to_def_id()</code>, seems to fix the problem, but items are still being removed from the index, but curiously by themselves. <a href="https://github.com/aDotInTheVoid/xmark/issues/5#issuecomment-739246919">Details</a>.</p>
<p>It looks like <code>&lt;JsonRenderer as FormatRenderer&gt;::item</code> is being called more that once, but I'm not sure why that would be</p>



<a name="218939393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Panic%20in%20json-format/near/218939393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nixon Enraght-Moony <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Panic.20in.20json-format.html#218939393">(Dec 05 2020 at 15:25)</a>:</h4>
<p>It this a bug that it's calling <code>item</code> with the same item twice?</p>



<a name="218939517"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Panic%20in%20json-format/near/218939517" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Panic.20in.20json-format.html#218939517">(Dec 05 2020 at 15:28)</a>:</h4>
<p>probably, I would investigate what's calling item twice</p>



<a name="218939526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Panic%20in%20json-format/near/218939526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Panic.20in.20json-format.html#218939526">(Dec 05 2020 at 15:28)</a>:</h4>
<p>the main HTML backend wouldn't notice, it would just overwrite the files</p>



<a name="218956967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Panic%20in%20json-format/near/218956967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nixon Enraght-Moony <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Panic.20in.20json-format.html#218956967">(Dec 05 2020 at 22:34)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/79751">Pull</a> that makes it work, but doesn't address the underlying duplication, as I haven't found it yet.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>